﻿<%@ Page Title="" Language="C#" MasterPageFile="~/admin/admin.master" AutoEventWireup="true" CodeFile="uni-report.aspx.cs" Inherits="admin_reports_reports" %>

<%@ Register Assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <script src="../../js/jquery.js" type="text/javascript"></script>
    <script src="../../bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
    <script type="text/javascript">        
        $('#myTab a').click(function (e) {
            e.preventDefault();
            $(this).tab('show');
        });
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="mainContent" Runat="Server">
    <div class="page-header">
        <h1>Reports <small>
            <asp:Label ID="uniLabel" runat="server" Text=""></asp:Label></small></h1>
    </div>
    <asp:HiddenField ID="UniID" runat="server" />
    <p><asp:LinkButton ID="LinkButton1" runat="server" 
        CssClass="btn btn-primary" onclick="LinkButton1_Click" ToolTip="Download all members details in excel format"><i class="icon-download icon-white"></i> Download CSV</asp:LinkButton></p>
    <ul class="nav nav-tabs" id="myTab">
      <li class="active"><a data-toggle="tab" href="#home">Career Interest</a></li>
      <li><a data-toggle="tab" href="#profile">Subject Area</a></li>
      <li><a data-toggle="tab" href="#messages">Degree</a></li>
      <li><a data-toggle="tab" href="#settings">Study Year</a></li>
      <li><a data-toggle="tab" href="#gender">Gender</a></li>
      <li><a data-toggle="tab" href="#paid">Paid/Unpaid</a></li>
    </ul>
 
    <div class="tab-content">
      <div class="tab-pane active" id="home">
          <asp:Chart ID="Chart1" runat="server" DataSourceID="CareerSqlDataSource" Height="600px" 
              Width="695px">
              <Series>
                  <asp:Series Name="Series1" ChartType="Bar" XValueMember="career_interest" YValueMembers="Column1" 
                      ChartArea="ChartArea1">
                  </asp:Series>
              </Series>
              <ChartAreas>
                  <asp:ChartArea Name="ChartArea1">
                  </asp:ChartArea>
              </ChartAreas>
          </asp:Chart>
          <asp:SqlDataSource ID="CareerSqlDataSource" runat="server" 
              ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" 
              SelectCommand="select count(*),career_interest from members where university_id=@uni group by career_interest">
              <SelectParameters>
                  <asp:ControlParameter ControlID="UniID" Name="uni" PropertyName="Value" />
              </SelectParameters>
          </asp:SqlDataSource>
      </div>
      <div class="tab-pane" id="profile">
        <asp:Chart ID="Chart4" runat="server" DataSourceID="SubjectAreaSqlDataSource" Height="600px" 
              Width="600px">
              <Series>
                  <asp:Series ChartType="Bar" Name="Series1" XValueMember="subject_area" YValueMembers="Column1">
                  </asp:Series>
              </Series>
              <ChartAreas>
                  <asp:ChartArea Name="ChartArea1">
                  </asp:ChartArea>
              </ChartAreas>
          </asp:Chart>
          <asp:SqlDataSource ID="SubjectAreaSqlDataSource" runat="server" 
              ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" 
              SelectCommand = "select count(*),subject_area from members where university_id=@uni group by subject_area">
              <SelectParameters>
                  <asp:ControlParameter ControlID="UniID" Name="uni" PropertyName="Value" />
              </SelectParameters>
          </asp:SqlDataSource>
      </div>
      <div class="tab-pane" id="messages">
          <asp:Chart ID="Chart5" runat="server" DataSourceID="DegreeTypeSqlDataSource" Height="600px" 
              Width="600px">
              <Series>
                  <asp:Series Name="Series1" ChartType="Pie" Legend="Legend1" XValueMember="degree_type" 
                      YValueMembers="Column1">
                  </asp:Series>
              </Series>
              <ChartAreas>
                  <asp:ChartArea Name="ChartArea1">
                  </asp:ChartArea>
              </ChartAreas>
              <Legends>
                  <asp:Legend Name="Legend1">
                  </asp:Legend>
              </Legends>
          </asp:Chart>
          <asp:SqlDataSource ID="DegreeTypeSqlDataSource" runat="server" 
              ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" 
              SelectCommand="select count(*),degree_type from members where university_id=@uni group by degree_type">
              <SelectParameters>
                  <asp:ControlParameter ControlID="UniID" Name="uni" PropertyName="Value" />
              </SelectParameters>
          </asp:SqlDataSource>
      </div>
      <div class="tab-pane" id="settings">
        <asp:Chart ID="Chart3" runat="server" DataSourceID="YearOfStudySqlDataSource" Height="600px" 
              Width="600px">
              <Series>
                  <asp:Series Name="Series1" ChartType="Pie" XValueMember="year_of_study" YValueMembers="Column1" 
                      Legend="Legend1">
                  </asp:Series>
              </Series>
              <ChartAreas>
                  <asp:ChartArea Name="ChartArea1">
                  </asp:ChartArea>
              </ChartAreas>
              <Legends>
                  <asp:Legend Name="Legend1">
                  </asp:Legend>
              </Legends>
          </asp:Chart>
          <asp:SqlDataSource ID="YearOfStudySqlDataSource" runat="server" 
              ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" 
              SelectCommand="select count(*),year_of_study from members where university_id=@uni group by year_of_study">
              <SelectParameters>
                  <asp:ControlParameter ControlID="UniID" Name="uni" PropertyName="Value" />
              </SelectParameters>
          </asp:SqlDataSource>
      </div>
      <div class="tab-pane" id="gender">
         <asp:Chart ID="Chart6" runat="server" DataSourceID="GenderSqlDataSource" Height="600px" 
              Palette="Bright" Width="600px">
              <Series>
                  <asp:Series ChartType="Pie" Legend="Legend1" Name="Series1" XValueMember="gender" 
                      YValueMembers="Column1">
                  </asp:Series>
              </Series>
              <ChartAreas>
                  <asp:ChartArea Name="ChartArea1">
                  </asp:ChartArea>
              </ChartAreas>
              <Legends>
                  <asp:Legend Name="Legend1">
                  </asp:Legend>
              </Legends>
          </asp:Chart>
          <asp:SqlDataSource ID="GenderSqlDataSource" runat="server" 
              ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" 
              SelectCommand="select count(*),gender from members where university_id=@uni group by gender">
              <SelectParameters>
                  <asp:ControlParameter ControlID="UniID" Name="uni" PropertyName="Value" />
              </SelectParameters>
        </asp:SqlDataSource>
      </div>
      <div class="tab-pane" id="paid">
          <asp:Chart ID="Chart7" runat="server" DataSourceID="PaidSqlDataSource" Height="600px" 
              Width="600px">
              <Series>
                  <asp:Series Name="Series1" ChartType="Pie" Legend="Legend1" XValueMember="paid" 
                      YValueMembers="Column1">
                  </asp:Series>
              </Series>
              <ChartAreas>
                  <asp:ChartArea Name="ChartArea1">
                  </asp:ChartArea>
              </ChartAreas>
              <Legends>
                  <asp:Legend Name="Legend1">
                  </asp:Legend>
              </Legends>
          </asp:Chart>
          <asp:SqlDataSource ID="PaidSqlDataSource" runat="server" 
              ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" 
              SelectCommand="select count(*),case when paid = 1 then 'Paid' else 'Unpaid' end paid from members where university_id=@uni group by paid">
              <SelectParameters>
                  <asp:ControlParameter ControlID="UniID" Name="uni" PropertyName="Value" />
              </SelectParameters>
          </asp:SqlDataSource>
      </div>
    </div>
</asp:Content>

